import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by fanshaohua on 2017/11/4.
 */
public class Demo {
    public static void main(String[] args){

        Course course = new Course("语文");

        course.selectCourse(new Students("王迎",27,"女"));
        course.selectCourse(new Students("王迎2",27,"女"));
        course.selectCourse(new Students("王迎3",27,"女"));
        course.selectCourse(new Students("王迎4",27,"女"));


        Students students[] = course.getStudentList();

        System.out.println(students);

        System.out.println(course.getStudentNumber());


        //基本类型 包装类型 自动拆装箱
        // int double float byte long short char boolean
         Integer a = 224;

         Double b = 2.3;

         Character c = 'a';

         a = Integer.MAX_VALUE; //查看 Integer 的最大值

        Integer.parseInt("123");  //parse 为压缩，此句意思为将 123 的字符串强制压缩为 数字 123

        System.out.println(a);

        //足够大的数字
        BigInteger big = new BigInteger("873580890878979879797986876786876869879707");
        BigInteger big2 = new BigInteger("8798798768768756785876876987078067908696987");

        System.out.println(big.multiply(big2));//乘法


        //处理大的 小数
        BigDecimal bigDecimal = new BigDecimal(1.3543646456364564564646464646446464646);
        BigDecimal bigDecimal1 = new BigDecimal(3.565646453645454656457567546456464646);

        System.out.println(bigDecimal.divide(bigDecimal1,5,BigDecimal.ROUND_HALF_UP));//除法,保留5位小数,四舍五入



        String s1 = "Welcome";

        String s4 = s1.replace("W","C");//将w换成c
        String s5 = s1.replaceFirst("w","C");

        String s6 = s1.split("l")[0];
        String s7 = s1.split("l")[1];


        //正则表达式

        boolean d = "java to learn".matches("java to learn"); //前面字符串和后面字符串是否匹配，正则

        //以java开头或以learn结尾就算匹配

        boolean e = "java to learn".matches("java.*");

        System.out.println(d+"and"+e);

        boolean f = "664170687@qq.ccc".matches("^[A-Za-z0-9\\u4e00-\\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$");
        System.out.println(f);


        Pattern p = Pattern.compile("a*b");
        Matcher m = p.matcher("aaaaab");
        boolean g = m.matches();


        StringBuilder builder = new StringBuilder("wang");//可以初始化内容，也可以为空

        builder.append("afasfasf").append("123123").append("dfsafsd");//向字符串中添加东西，如果添加东西较多，则用这上下两种，不要用+连接，效率低

        System.out.println(builder.toString());



        StringBuffer buffer = new StringBuffer("wang");

        buffer.append("afasfasf").append("123123").append("dfsafsd");

        System.out.println(buffer.toString());
        //StringBuilder 线程不安全，效率高，快    Buffer 线程安全，多个线程同时操作不会造成数据混乱，效率低，多线程时候使用


    }
}
